package com.surpassun.emall.service;

import java.util.List;

import com.surpassun.emall.exception.NoSuchRoleException;
import com.surpassun.emall.model.Permission;
import com.surpassun.emall.model.Role;

public interface RoleService extends AbstractService<Role> {

	public void addRole(String name, String description, List<Permission> permissions);
	
	public void updateRole(Role role, String name, String description, List<Permission> permissions);
	
	
	/**
	 * If the role with the "roleId" cannot be found, this method will throw an NoSuchRoleException
	 * 
	 * @param roleId
	 * @param name
	 * @param description
	 * @param permissions
	 * @return
	 * @throws NoSuchRoleException
	 */
	public void updateRole(long roleId, String name, String description, List<Permission> permissions) throws NoSuchRoleException;
	
	
	/**
	 * This method will replace the original permissions and put the new ones into database
	 * 
	 * @param permissions
	 */
	public void updateRolePermissions(Role role, List<Permission> permissions);
	
	public void updateRolePermissions(long roleId, List<Permission> permissions) throws NoSuchRoleException;
	
	
	/**
	 * This method will add the permissions in the parameter into the existed ones
	 * The old permissions will not be replaced
	 * 
	 * @param permissions
	 */
	public void addRolePermissions(Role role, List<Permission> permissions);

	public void addRolePermissions(long roleId, List<Permission> permissions) throws NoSuchRoleException;
	
	public Role addRoleAdmin();

	public Role getRole(String roleName);

}
